<?php if (isset( $_SESSION['id']) == NULL ): { ?>

<a style="color: #FFF; margin-left: 50px;">LOGIN</a>
<div  align="left" style="margin-left: 150px; margin-top: -30px" ><form method="POST">
        <p><a style="color: white">Username</a>
            <input type="text" name="username" placeholder="Username or Email"></p>
        <p style="margin-left: 4px"><a style="color: white">Password</a>
            <input type="password" name="password" placeholder="password">
        <p style="margin-left: 150px"><input  type="submit" name="submit" value="Login">
    </form></div>
<?php } endif;?>
<?php require_once 'user.php'; ?>
<?php if (isset($_POST['submit'])): ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $isOk = FALSE;
    $index = -1;
    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $username) == 0) &&
                (strcmp($users[$i]['password'], $password) == 0)) {
            $isOk = TRUE;
            $index = $i;
        }
    }
    if ($isOk) {
        $_SESSION["id"] = $users[$index]["id"];
        header("Location: index3.php");
    } else {
        echo 'lỗi';
    }
    ?>
<?php endif; ?>